<template>
  <div>
    <el-row :gutter="7">
      <el-form
        ref="elForm"
        :model="formData"
        :rules="rules"
        size="medium"
        label-width="115px"
      >
        <el-col :span="23">
          <el-form-item label="关联工单类型" prop="field101">
            <el-select
              v-model="formData.field101"
              placeholder="请选择关联工单类型"
              clearable
              :style="{ width: '100%' }"
            >
              <el-option
                v-for="(item, index) in field101Options"
                :key="index"
                :label="item.label"
                :value="item.value"
                :disabled="item.disabled"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="23">
          <el-form-item label="" prop="field102">
            <el-checkbox-group v-model="formData.field102" size="medium">
              <el-checkbox
                v-for="(item, index) in field102Options"
                :key="index"
                :label="item.value"
                :disabled="item.disabled"
                >{{ item.label }}</el-checkbox
              >
            </el-checkbox-group>
          </el-form-item>
        </el-col>
        <el-col :span="23">
          <el-form-item label="" prop="field103">
            <el-checkbox-group v-model="formData.field103" size="medium"   @click="showform=!showform">
              <el-checkbox
                v-for="(item, index) in field103Options"
                :key="index"
                :label="item.value"
                :disabled="item.disabled"
              
                >{{ item.label }}</el-checkbox
              >
            </el-checkbox-group>
          </el-form-item>
        </el-col>
        <el-col
          :span="23"
          style="background: #f8f9fc; padding: 30px 30px; margin-bottom: 20px"
          v-show="formData.field103.length>0"
        >
          <el-col :span="24">
            <el-form-item label="工单生成周期" prop="field104">
              <el-select
                v-model="formData.field104"
                placeholder="请选择工单生成周期"
                clearable
                :style="{ width: '100%' }"
              >
                <el-option
                  v-for="(item, index) in field104Options"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  :disabled="item.disabled"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24"></el-col>
          <el-col :span="24">
            <el-form-item label="工单优先级" prop="field105">
              <el-select
                v-model="formData.field105"
                placeholder="请选择工单优先级"
                clearable
                :style="{ width: '100%' }"
              >
                <el-option
                  v-for="(item, index) in field105Options"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  :disabled="item.disabled"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24"></el-col>
          <el-col :span="10">
            <el-form-item label="工单完成期限" prop="field110">
              <el-input-number
                v-model="formData.field110"
                placeholder="工单完成期限"
                controls-position="right"
              >
              </el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="" prop="field111">
              <el-select
                v-model="formData.field111"
                placeholder="请选择"
                clearable
                :style="{ width: '100%' }"
              >
                <el-option
                  v-for="(item, index) in field111Options"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  :disabled="item.disabled"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-col>
        <el-col :span="24" style="text-align: center">
          <el-form-item size="large">
            <el-button type="primary" @click="submitForm" style="width: 40%" v-show="showSave"
              >保存</el-button
            >
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script>
export default {
  components: {},
props: {
  showSave: {
    type: Boolean,
    default: true
  },
},
  data() {
    return {
      formData: {
        field101: undefined,
        field102: [1],
        field103: [],
        field104: 1,
        field105: undefined,
        field110: 1,
        field111: 1,
      },
      rules: {
        field101: [
          {
            required: true,
            message: "请选择关联工单类型",
            trigger: "change",
          },
        ],
        field102: [
          {
            required: true,
            type: "array",
            message: "请至少选择一个field102",
            trigger: "change",
          },
        ],
        field103: [
          {
            // required: true,
            type: "array",
            // message: "请至少选择一个field103",
            trigger: "change",
          },
        ],
        field104: [
          {
            required: true,
            message: "请选择工单生成周期",
            trigger: "change",
          },
        ],
        field105: [
          {
            required: true,
            message: "请选择工单优先级",
            trigger: "change",
          },
        ],
        field110: [
          {
            required: true,
            message: "工单完成期限",
            trigger: "blur",
          },
        ],
        field111: [
          {
            required: true,
            message: "请选择",
            trigger: "change",
          },
        ],
      },
      field101Options: [
        {
          label: "运维工单",
          value: '运维工单',
        },
        
      ],
      field102Options: [
        {
          label: "工单结束自动关闭事件",
          value: 1,
        },
      ],
      field103Options: [
        {
          label: "自动生成工单",
          value: 1,
        },
      ],
      field104Options: [
        {
          label: "间隔1小时",
          value: 1,
        },
        {
          label: "间隔4小时",
          value: 2,
        },
      ],
      field105Options: [
        {
          label: "低",
          value: 1,
        },
        {
          label: "中",
          value: 2,
        },
        {
          label: "高",
          value: "",
        },
      ],
      field111Options: [
        {
          label: "小时以内",
          value: 1,
        },
        {
          label: "天以内",
          value: 2,
        },
      ],
    };
  },
  computed: {},
  watch: {},
  created() {},
    mounted() {
 
  },
  methods: {
    submitForm() {
      this.$refs["elForm"].validate((valid) => {
        if (!valid) return;
        // TODO 提交表单
      });
    },
    resetForm() {
      this.$refs["elForm"].resetFields();
    },
  },
};
</script>
<style>
</style>
